package com.example.campus.mapper;

import com.example.campus.pojo.dto.UserPageQueryDTO;
import com.example.campus.pojo.dto.UserStatusChangeDTO;
import com.example.campus.pojo.entity.User;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {
    User getByUsernameOrPhone(String username, String phone);

    void insert(User user);

    @Select("select * from user where id = #{id}")
    User getById(Long id);

    void update(User user);

    Page<User> getUserList(UserPageQueryDTO userPageQueryDTO);

    @Update("update user set status = #{status} where id = #{userId}")
    void changeUserStatus(UserStatusChangeDTO userStatusChangeDTO);

    @Select("select count(*) from user")
    Long getUserTotal();
}
